home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / c / c-tools-.000 / c-tools- / c-tools-0.4 / examples / tst / highlight.out next >
Encoding:
Text File  |  1995-08-13  |  2.5 KB  |  46 lines

  1. /* output of `highlight stripcr.c highlight.out' */
  2. /* stripcr.c -- remove carriage returns from input file */
  3. #include <string.h>
  4. #include <stdio.h>
  5. #include <ctype.h>
  6. #include <assert.h>
  7. int main(int argcchar **argv)
  8. {
  9.     FILE *fin = stdin*fout = stdout;
  10.     int c;
  11.     if (argc > 1) {
  12.     if (!strcmp(argv[1]"-h") || argc > 3) {
  13.         fprintf(stderr"\
  14. %s: remove carriage returns from input file\n\
  15. usage: %s [input] [[output]]\n", argv[0]argv[0]);
  16.         exit(0);
  17.     } else {
  18.         if (strcmp(argv[1]"-") != 0 &&
  19.         (fin = fopen(argv[1]"rb")) == NULL) {
  20.         fprintf(stderr"%s: no such file\n"argv[1]);
  21.         exit(1);
  22.         }
  23.     }
  24.     if (argc == 3) {
  25.         if ((fout = fopen(argv[2]"wb")) == NULL) {
  26.         fprintf(stderr"%s: cannot open output file\n"argv[2]);
  27.         exit(1);
  28.         }
  29.     }
  30.     }
  31.     while ((c = fgetc(fin)) != EOF)
  32.     if (c != 0x0d)
  33.         fputc(cfout);
  34.     fclose(fin);
  35.     fclose(fout);
  36.     return 0;
  37. }
  38. /* stripcr.c ends here */
  39.